﻿@model System.Data.DataTable           
@using Jb.Web.Utility;
@using Jb.Common.Extensions;
@using Jb.Common.DB;
@using Jb.Web.ViewModels;

@{
    JobAppListType _ListType = (JobAppListType)ViewData[AppConstants.ViewDataKeys.LIST_TYPE];    
    
    MvcHtmlString _AdjustmentStyle = MvcHtmlString.Create(" style='margin-top: -10px;' ");
    if (WebUtil.IsMobileRequest())
    {
        _AdjustmentStyle = MvcHtmlString.Create(String.Empty);
    }
}

@if (Model.Rows.Count > 0) {
    for (int i = 0; i < Model.Rows.Count; i++) {
        System.Data.DataRow _Row = Model.Rows[i];
        int _ApplicationID = NullHandler.GetInt(_Row["ID"]);
        String _JobSeekerPhoto = ImageManager.GetJobSeekerPhotoUrl(NullHandler.GetString(_Row["PhotoFile"]), NullHandler.GetInt(_Row["JobSeekerID"]));
        String _Name = Html.FormatData(_Row["JobSeekerName"]);
        String _DownloadUrl = Url.ResumeDownloadUrl(NullHandler.GetInt(_Row["ResumeID"]));
        int _InterviewID = NullHandler.GetInt(_Row["InterviewRequestID"]);
        
        <div class="jb-job row-fluid" style="padding-left:0px; padding-right:0px;">
            <div class="span2">
                <img class="jb-js-photo" src="@(_JobSeekerPhoto)" alt="@(_Name)" title="@(_Name)" />
            </div>
            <div class="span10">
                <div@(_AdjustmentStyle)>
                    <h2><small><a href="@(_DownloadUrl)">@_Name</a></small></h2>
                    @if(_ListType != JobAppListType.JobSeekersList && !NullHandler.GetBoolean(_Row["HasRead"])){                        
                    <span class="label label-warning">Unread</span>
                    }
                </div>
                
                <div class="jb-label-hint">
                    Applied On: @NullHandler.GetDateTime(_Row["AppliedOn"]).ToString(AppConstants.ValueOf.DATE_FROMAT_DISPLAY_WITH_TIME)
                </div>
                <div>
                    @Html.Raw(Html.FormatData(WebUtil.GetFormattedJobDescription(NullHandler.GetString(_Row["SnapShot"]))))
                </div>
                <div>
                    <a class="btn btn-mini btn-primary" href="javascript:void(0);" onclick="ShowApplication(@(_ApplicationID));"><i class="icon-star icon-white"></i> View Application</a>
                    <a class="btn btn-mini" href="@(_DownloadUrl)" rel="tooltip" data-original-title="@(_Row["FileName"])"><i class="icon-download-alt"></i> Download Resume</a>                                        
                    @if (_ListType == JobAppListType.All)
                    {
                        if (NullHandler.GetBoolean(_Row["HasShortListed"]))
                        {
                            <a class="btn btn-mini disabled" href="javascript:void(0);"><i class="icon-filter"></i> Short Listed</a>
                        }
                        else
                        {
                            <a class="btn btn-mini" href="javascript:void(0);" onclick="ShortList(@(_ApplicationID), this);"><i class="icon-filter"></i> Short List</a>
                        }
                    }
                    @if(_ListType == JobAppListType.All || _ListType == JobAppListType.ShortListed){
                        if (_InterviewID > 0 && NullHandler.GetBoolean(_Row["HasMessageSent"]))
                        {   
                            <a class="btn btn-mini disabled" href="javascript:void(0);"><i class="icon-star-empty"></i> Called for Interview</a>
                        }
                        else{
                            <a class="btn btn-mini" href="javascript:void(0);" onclick="ShowInterviewRequestDialog(@(_ApplicationID), this);"><i class="icon-star-empty"></i> Call for Interview</a>
                        }
                    }
                    @if(_ListType == JobAppListType.JobSeekersList){
                        <a class="btn btn-mini" href="@(Url.JobDetailsUrl(NullHandler.GetInt(_Row["JobID"]), NullHandler.GetString(_Row["JobUrl"])))" target="_blank"><i class=""></i> Job Details</a>
                    }
                </div>
            </div>
            <input type="hidden" id="hdnInterviewID_@(_ApplicationID)" value="@(_InterviewID)" />
            <div id="divCoverLetter_@(_ApplicationID)" class="hidden">@Html.Raw(Html.FormatData(NullHandler.GetString(_Row["CoverLetter"])))</div>
        </div>
    }
}